package com.pro.controller;/*
    @description: TDD
    @author: 赵自强
    @date: 2022/1/27 5:43
*/

import com.pro.pojo.JsUser;
import com.pro.pojo.JsUserOrder;
import com.pro.pojo.JsonData;
import com.pro.service.OrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/order")
public class OrderController {

    @Autowired
    private OrderService orderService;


    /*
     * create by: 赵自强
     * create time: 2022/1/27 5:47
     * @return com.pro.pojo.JsonData
     * 获取所有课程订单&&检索 getCourseOrders JsUserOrder jsUserOrder
     */
    @RequestMapping("/getCourseOrders")
    public JsonData getCourseOrders(JsUserOrder jsUserOrder){
        List<JsUserOrder> courseOrders = orderService.getCourseOrders(jsUserOrder);
        return courseOrders!=null?JsonData.buildSuccess(courseOrders):JsonData.buildError("后台数据错误");
    }

    /*
     * create by: 赵自强
     * create time: 2022/1/27 20:18
     * @return com.pro.pojo.JsonData
     * 查询主讲师&&商家名称 getUserById Integer userId
     */
    @RequestMapping("/getUserById")
    public JsonData getUserById(Integer userId){
        JsUser userById = orderService.getUserById(userId);
        return userById!=null?JsonData.buildSuccess(userById):JsonData.buildError("后台数据错误");
    }
    /*
     * create by: 赵自强
     * create time: 2022/1/27 20:30
     * @return com.pro.pojo.JsonData
     * 获取商品订单&&检索 getGoodsOrders JsUserOrder jsUserOrder
     */
    @RequestMapping("/getGoodsOrders")
    public JsonData getGoodsOrders(JsUserOrder jsUserOrder){
        List<JsUserOrder> goodsOrders = orderService.getGoodsOrders(jsUserOrder);
        return goodsOrders!=null?JsonData.buildSuccess(goodsOrders):JsonData.buildError("后台数据错误");
    }

    /*
     * create by: 赵自强
     * create time: 2022/2/8 13:51
     * @return com.pro.pojo.JsonData
     * 删除订单 delOrder Integer orderId
     */
    @RequestMapping("/delOrder")
    public JsonData delOrder(Integer orderId){
        Boolean delOrder = orderService.delOrder(orderId);
        return delOrder?JsonData.buildSuccess(delOrder):JsonData.buildError("后台数据错误");
    }


}
